﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLFacade.entities;
using BLFacade;

namespace ProjectUI
{
    public partial class EmployeeListForm : Form
    {
        public EmployeeListForm()
        {
            InitializeComponent();
            gridViewEmployees.AutoGenerateColumns = false;
            gridViewEmployees.DataSource = FacadeHolder.DataFacade.GetEmployees();
            this.Text = "All employees";
        }

        private void gridViewEmployees_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int index = gridViewEmployees.SelectedCells[0].RowIndex;
            EmployeeForm info = new EmployeeForm(((List<IEmployee>)gridViewEmployees.DataSource)[index]);
            info.MdiParent = this.MdiParent;
            info.Show();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            EmployeeForm info = new EmployeeForm();
            info.MdiParent = this.MdiParent;
            info.Show();
            this.Close();
        }

        //public void UpdateDataSource()
        //{
        //    gridViewEmployees.DataSource = FacadeHolder.DataFacade.GetEmployees();
        //}
    }
}
